/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Description: Spinlock Configuration.
 * AutoGenerate Code, DO NOT EDIT!!!
 * {{get_generation_time()}}
 * {{get_project_name()}}
 * {{get_vcos_version()}}
 */

/* Including File */
#include <nuttx/config.h>
#include "spinlock_cfg.h"
#include "os_spinlock.h"
#include "os_application.h"
#include "application_cfg.h"
#include "os_compiler_cfg.h"

#if defined(CONFIG_RT_FRAMEWORK_SPINLOCK) && (CONFIG_RT_FRAMEWORK_SPINLOCK == 1)

/* Local Macro Definition */

/* Local Enumeration Definition */

/* Local type & Structure Definition */

/* global Variable Definition */
{%- set spinlock_cfg = get_spinlock_cfg() %}
{%- for spin_id, spin_val in spinlock_cfg.items() %}
    {%- set sid_u = spin_id.upper() %}
    {%- set app_mask = get_access_app_mask(spin_val["AccessingApplication"], index_size=35) %}

DeclareSpinlock(OS_GLOBAL_VAR_NO_INIT_SECTION, {{sid_u}}) = {
    /* .obj_desc = */            &SPINLOCKOBJVAR({{sid_u}}),
    /* .method = */              {{spin_val["Method"]}},
#if defined(CONFIG_RT_FRAMEWORK_MULTIAPP) && (CONFIG_RT_FRAMEWORK_MULTIAPP== 1)
    /* .access_app_mask = */     ({{app_mask}}),
#endif
    /* .check = */               {{spin_val["LockType"]}},
    /* .spin_id  = */            {{sid_u}},
    /* .order = */               {{spin_val["Order"]}},
};
{%- endfor %}

DeclareOsRefTable(spinlock, OS_SPINLOCK_CNT) = {
{%- for spinlock in spinlock_cfg %}
    &SPINLOCKCFGVAR({{spinlock.upper()}}),
{%- endfor %}
};

#endif /* (CONFIG_RT_FRAMEWORK_SPINLOCK == 1) */

/* Local Variable Definition */

/* Local Function Declaration */

/* Local Function Implementation */

/* global Function Implementation */

